 <template>
  <!-- 详细内容页面 -->
  <div id="container">
    <el-collapse v-model="activeNames" v-loading="loading">
      <el-collapse-item title="基本信息" name="1">
        <purchase-request-detail
          ref="detail"
          :data="purchaseRequestDetail"
        ></purchase-request-detail>
      </el-collapse-item>
      <el-collapse-item title="审批流程" name="2">
        <check-process
          ref="checkProcess"
          :id="$route.query.id"
          :type="22"
        ></check-process>
      </el-collapse-item>
    </el-collapse>
    <auth-buttons
      :info="{ type: 22, mainId: $route.query.id }"
      @updatePage="updatePage"
    ></auth-buttons>
  </div>
</template>
<script>
import purchaseRequestDetail from './components/purchaseRequestDetail.vue'
import checkProcess from '@/components/checkProcess/checkList'
import authButtons from '@/components/authButtons'
export default {
  name: 'detail',
  data () {
    return {
      activeNames: ['1'],
      loading: false,
      purchaseRequestDetail: {}
    }
  },
  components: {
    purchaseRequestDetail,
    checkProcess,
    authButtons
  },
  mounted () {
    this.getDetail()
  },
  methods: {
    async getDetail () {
      let param = {
        limit: 1000,
        page: 1,
        id: this.$route.query.id
      }
      this.loading = true
      let { data } = await this.$API.purchase.getPurchaseRequestList.get(param)
      this.loading = false
      this.activeNames.push('2')
      this.purchaseRequestDetail = data[0]
    },
    updatePage () {
      this.getDetail()
      this.$refs.detail.relodPart()
      this.$refs.checkProcess.relodPart()
    },
  }
}
</script>
<style lang='scss' scoped>
#container {
  margin: 10px;
  :deep(.el-collapse-item__header) {
    padding-left: 20px;
    font-size: 16px;
  }
  :deep(.el-collapse-item__content) {
    padding: 0 20px 20px 20px;
  }
  :deep(.el-form-item) {
    margin-bottom: 5px;
  }
  :deep(.el-form-item__label) {
    color: #999;
  }
}
</style>